<html>
<script>
const queryMap = {};
for (const item of location.search.substr(1).split('&')) {
  const [key, value] = item.split('=');
  queryMap[key] = value;
}

const test_url = queryMap.url + '?allow=' + queryMap.allow;

function finish(result) { document.title = result; }

const xhr = new XMLHttpRequest();
xhr.open('GET', test_url);
xhr.setRequestHeader('X-NotSimple', 'true');
xhr.addEventListener('error', e => {
  finish('FAIL');
});
xhr.addEventListener('load', e => {
  console.log('status = ' + xhr.status);
  if (xhr.response !== queryMap.response_text &&
      queryMap.response_text !== 'unused') {
    return finish('FAIL: response text does not match');
  }
  finish('PASS');
});
xhr.send();
</script>
</html>
